﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed
#pragma once

#include "GcmpModelInterface.h"
#include "IElementJoinBehavior.h"

namespace gcmp
{
    class IDocument;
    class ElementId;

    /// \brief Instance的连接行为
    class GCMP_MODEL_INTERFACE_EXPORT IInstanceJoinBehavior : public IElementJoinBehavior
    {
        DEFINE_CAST_DERIVED(gcmp::IInstanceJoinBehavior, gcmp::IElementJoinBehavior)

    public:

        /// \brief 创建Instance的连接行为
        /// \param pDocument 当前文档
        /// \param joinType 连接类型
        /// \param isChangeJoinTypeAllowed 是否允许切换连接类型
        /// \return 连接行为
        static OwnerPtr<IElementJoinBehavior> CreateInstanceJoinBehavior(IDocument* pDocument, JoinType joinType, bool isChangeJoinTypeAllowed = true);

        /// \brief 获取连接类型
        /// \return 连接类型
        virtual JoinType GetJoinType() = 0;

        /// \brief 判断是否允许切换平接与方接
        /// \return 返回true代表允许，返回false代表不允许
        virtual bool IsChangeJoinTypeAllowed() const = 0;

        /// \brief 设置是否允许切换平接与方接
        /// \param isChangeJoinTypeAllowed 是否允许切换平接与方接，true代表允许，false代表不允许
        /// \return 成功返回true，失败返回false
        virtual bool SetIsChangeJoinTypeAllowed(bool isChangeJoinTypeAllowed) = 0;

        /// \brief 判断是否允许切换主次关系
        /// \return 返回true代表允许，返回false代表不允许
        virtual bool IsChangePriAndSecAllowed() const = 0;

        /// \brief 设置是否允许切换主次关系
        /// \param isChangePriAndSecAllowed 是否允许切换主次关系，true代表允许，false代表不允许
        /// \return 成功返回true，失败返回false
        virtual bool SetIsChangePriAndSecAllowed(bool isChangePriAndSecAllowed) = 0;

        /// \brief 获得连接类型RdId
        /// \return 连接类型的RdId
        virtual RegenDataId GetElementJoinTypeRdId() const = 0;

        /// \brief 标记连接类型RdId
        /// \return void
        virtual void MarkElementJoinTypeRdId() = 0;
    };
}


